package com.allwees.bs.module.scm.mq.listener;

import com.allwees.bs.module.oms.bo.OmsOrderStabledBo;
import com.allwees.bs.module.scm.service.ScmAllocateOrderSkuService;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

@Component
@RabbitListener(queues = "q.OMS_SCM.OmsOrder.Stabled")
public class OmsOrderStabledMqListener {

    @Autowired
    private ScmAllocateOrderSkuService allocateOrderSkuService;

    @RabbitHandler
    public void onEvent(OmsOrderStabledBo orderStabledBo) {
        if (CollectionUtils.isEmpty(orderStabledBo.getOrderItems())) {
            return;
        }
        allocateOrderSkuService.create(orderStabledBo.getOrderItems());
    }
}
